import dayjs from "dayjs";
import { getSettingsApi } from "@/api/modules/homepage.js";
let globalData = null
export default {

	data(){
		return {
			globalData: {
				title: ''
			}
		}
	},
	computed: {},

	onShareAppMessage() {

	},

	onLoad() {
		if(globalData) {
			this.setGlobalData(globalData)
			return
		} 
		getSettingsApi().then(res => {
			globalData = res;
			this.setGlobalData(res)
			console.log(this.globalData);
		})
	},

	onShow() {
    uni.hideTabBar({
      animation: false
    });
  },

	methods: {
		setGlobalData(res) {
			Object.keys(res).forEach(key => {
				this.$set(this.globalData, key,res[key] )
			});
			this.$store.commit('SET_TABBAR_RULES', res.tsAppletFunction)
		},

		getImgUrl(url){
			if(!url) return 
			if(url.indexOf('http') > -1) return url
			return this.$baseImgUrl + url
		},

		$timeFilter(tm, format) {
			return dayjs(tm).format(format)
		},

	
	},
};